<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/templates/padrao.xhtml">
    <ui:define name="page">
        <ui:insert name="formGrowl">
            <p:growl id="growl" life="10000" />
        </ui:insert>

        <h:form id="formCad">
            <ui:insert name="formMessages">
                <p:messages id="formMessages" />
            </ui:insert>
            <p:panel id="panelCadastro" header="#{pPageTitle}" style="border:0px">
                <br/>
                <h:panelGrid columns="2" columnClasses="textAlignLeft,textAlignLeft">
                    <p:selectOneMenu value="#{fichaView.lote}" 
                                     label="Lote" 
                                     filter="true" filterMatchMode="exact"
                                     converter="#{loteConverter}" rendered="true">
                        <f:selectItem itemLabel="Selecione um Lote" noSelectionOption="true"/>
                        <f:selectItems value="#{fichaView.lotes}" var="lote" 
                                       itemValue="#{lote}" 
                                       itemLabel="#{lote.id}"/>
                    </p:selectOneMenu>
                    <p:commandButton ajax="false" type="submit" icon="ui-icon-search" action="#{fichaView.filtraFichas}"/>
                    <p:commandButton ajax="false" value="Teste iReport" type="submit" icon="ui-icon-search" action="#{fichaView.imprimeRelatorio}"/>
                </h:panelGrid>
                <br/>
                <h:panelGrid id="panelFields" >
                    <p:dataTable id="tableRecords" emptyMessage="Nenhum registro encontrado"
                                 selection="#{pTarget}"  selectionMode="single" rowKey="#{obj.id}" value="#{pListaRecords}" var="obj" rows="10"
                                 paginator="true"  rowsPerPageTemplate="10,20,30,40,50" paginatorPosition="bottom"
                                 paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
                        <ui:insert name="dataTable"></ui:insert>
                    </p:dataTable>
                    <h:panelGrid columns="2">  
                        <p:panel header="Exportar dados">  
                            <h:commandLink>  
                                <p:graphicImage value="/resources/imagens/excel.png" />  
                                <p:dataExporter type="xls" target="tableRecords" fileName="dados" />  
                            </h:commandLink>  
                            <h:commandLink>  
                                <p:graphicImage value="/resources/imagens/pdf.png"/>  
                                <p:dataExporter type="pdf" target="tableRecords" encoding="iso-8859-1" preProcessor="#{fichaView.preProcessPDF}" fileName="fichas"/>  
                            </h:commandLink>  
                        </p:panel>  
                    </h:panelGrid>
                </h:panelGrid>
            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>
